home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / RLaB / testmatrix / hanowa.r < prev    next >
Text File  |  1994-12-27  |  1KB  |  48 lines

  1. //-------------------------------------------------------------------//
  2.  
  3. // Synopsis:    hanowa: A matrix whose eigenvalues lie on a vertical 
  4. //              line in the complex plane. 
  5.  
  6. // Syntax:      hanowa (N, d) 
  7.  
  8. // Description:
  9.  
  10. //      hanowa (N, d) is the N-by-N block 2x2 matrix (thus N = 2M must be even)
  11.  
  12. //                      [d*eye(m),   -diag(1:m)
  13. //                       diag(1:m),   d*eye(m)]
  14.  
  15. //      It has complex eigenvalues:
  16.  
  17. //      lambda(k) = d +/- k*i (1 <= k <= M).  
  18. //      Parameter d defaults to -1.
  19.  
  20. //      Reference:
  21. //      E. Hairer, S.P. Norsett and G. Wanner, Solving Ordinary
  22. //      Differential Equations I: Nonstiff Problems, Springer-Verlag,
  23. //      Berlin, 1987. (pp. 86-87)
  24.  
  25. //    This file is a translation of hanowa.m from version 2.0 of
  26. //    "The Test Matrix Toolbox for Matlab", described in Numerical
  27. //    Analysis Report No. 237, December 1993, by N. J. Higham.
  28.  
  29. //-------------------------------------------------------------------//
  30.  
  31. hanowa = function (n, d)
  32. {
  33.   local (n, d)
  34.  
  35.   if (!exist (d)) { d = -1; }
  36.  
  37.   m = n/2;
  38.   if (round(m) != m)
  39.   {
  40.     error ("N must be even.");
  41.   }
  42.  
  43.   A = [ d*eye(m, m), -diag(1:m);
  44.         diag(1:m),  d*eye(m, m)];
  45.  
  46.   return A;
  47. };
  48.